const Router = require('koa-router')
const router = new Router()
const request = require('request')

router.get('/smile/list', async (ctx) => {
  const page = ctx.query.page
  
  const getData = () => {
    return new Promise((resolve, reject) => {
      request('http://www.mxnzp.com/api/jokes/list?page=' + page, (err, res, body) => {
        resolve(body)
      })
    })
  }

  const data = await getData()
  ctx.body = data
})

module.exports = router